// 创建时间: Sat December 14 21:00:00 2021
// 作者: Zhouzihao - Nanjing University of Aeronautics and Astronautics

const net = require('net');

const host = '127.0.0.8';
const port = 30000;

const client = new net.Socket();

client.connect(port, host, () => {
    console.log('Connected to server');
    
    const message = 'javascript_to_plant successful!!';
    
    // 发送消息到服务器
    client.write(message);
});

client.on('data', (data) => {
    console.log('Received from server:', data.toString());
    
    // 接收消息后，关闭连接
    client.destroy(); 
});

client.on('close', () => {
    console.log('Connection closed');
});

client.on('error', (err) => {
    console.error('Connection error:', err.message);
});
